package StudyBuddy;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Ra
 */
public class Sort {
    
    public String[] sort(String[] text)
    {
        int indexFirst = -1;
        int indexLast = -1;
        String subString1 = null;
        String subString2 = null;
        int sub1 = 0;
        int sub2 = 0;
        
         for(int k = 0; k <= text.length; k++)  
         {  int i = 0;
            int j = 1;
           

            while( j < text.length)
            {

                String temp = null;
          //      System.out.println("First contains " + text[i]);
          //      System.out.println("Second contains " + text[j]);
                 indexFirst =  text[i].indexOf("&");
                 indexLast = text[i].lastIndexOf("&");
                 indexFirst++;
                 subString1 = text[i].substring(indexFirst, indexLast++);
                 
                 indexFirst =  text[j].indexOf("&");
                 indexLast = text[j].lastIndexOf("&");
                 indexFirst++;
                 subString2 = text[j].substring(indexFirst, indexLast++);
                  
                 //array = subString1.toCharArray();
                // sub1 = Integer.valueOf(subString1).intValue();
                // sub1 = Integer.valueOf(subString1)
                 
               //  System.out.println("SubString 1 " + subString2);
              //   sub1 = Integer.getInteger(subString1);
                 sub1 = Integer.parseInt(subString1);
                 sub2 = Integer.parseInt(subString2);
                 
                
                

                if (sub1 < sub2)
                {

                    temp = text[i];
                    text[i] = text[j];
                    text[j] = temp;


                }
                i++;
                
                if (j < text.length)
                {
                    j++;
                }

            }
      }
         return text;
    }
    
    
   }
    


